<template>

  <el-collapse-item name="converntion">
    <template #title>
      <el-icon>
        <Setting />
      </el-icon>常规
    </template>
    <div>
      <el-form label-width="auto">
        <el-form-item label="节点ID：">
          <el-text>{{ element.id }}</el-text>
        </el-form-item>
        <el-form-item label="节点名称：">
          <el-text>{{ element.name }}</el-text>
        </el-form-item>
        <el-form-item label="自定义名称：">
          <el-col :span="18">
            <el-input v-model="elementName"></el-input>
          </el-col>
          <el-col :span="1"></el-col>
          <el-col :span="5">
            <el-button @click="handlerUpdataName" plain type="primary"><el-icon>
                <Edit />
              </el-icon></el-button>
          </el-col>

        </el-form-item>
      </el-form>
    </div>
  </el-collapse-item>

</template>

<script setup>
import { defineProps, ref } from 'vue';
const element = defineModel("element", {
  default: {
    id: '',
    name: '',
    type: ''
  }
})
const props = defineProps({
  bpmnModeler: Object
})
const elementName = ref('')
function handlerUpdataName() {
  element.value.name = elementName.value
  if (elementName.value) {
    const editElement = props.bpmnModeler.get("elementRegistry").get(element.value.id)
    const modeling = props.bpmnModeler.get("modeling")
    modeling.updateProperties(editElement, { name: elementName.value })
    elementName.value = ''
  }
}
</script>

<style lang="less" scoped>
:deep(.el-collapse-item__header) {
  font-weight: 700;
  background-color: var(--el-color-primary-light-9);
  border-radius: 10px;
}

.el-icon {
  margin: 0 10px;
}
</style>